{extends file='layout/main.html'}
{block name="main"}

<div class="main_title">
	<h2>图片/视频</h2>
	<p>列表及管理</p>
</div>

<div class="btn_blk">
	<div class="fr">
		<a href="#" class="btn2 fr ml20 del_all">删除</a>
	</div>
</div>
<form action="?url=item/delete" method="post" accept-charset="utf-8" id="res_del">
<table width="100%" class="table_list">
	<tr>
		<th width="55"><input type="checkbox" class="checkAll" rel="check[]"/></th>
		<th width="20%">标题</th>
		<th>价格</th>
		<th>类型</th>
		<th>是否推荐</th>
		<th>状态</th>
		<th>发布人</th>
		<th>发布时间</th>
		<th>操作</th>
	</tr>
	{foreach $data as $val}
	<tr{if $val@iteration % 2} class="odd"{/if}>
		<td><input type="checkbox" name="check[]" value="{$val.id}"></td>
		<td>{$val.title}</td>
		<td>{$val.price}</td>
		<td>{if $val.type==1}视频{else}图片{/if}</td>
		<td>
			{if $val.is_recommend==1}<font color="red">是</font>{/if}
			{if $val.is_recommend==0}否{/if}
		</td>
		<td>
			{if $val.status==0}未审核{/if}
			{if $val.status==1}已审核{/if}
		</td>

		<td>{get_info('cooper',$val.cooper_id,'name')}</td>
		<td>
			{date('Y-m-d H:i:s', $val.add_time)}
		</td>
		<td class="tc">
			<a href="{$val.id}" class="tuijian">
				{if $val.is_recommend==0}推荐{/if}
				{if $val.is_recommend==1}取消推荐{/if}
			</a>&nbsp;&nbsp;
			<a href="{$val.id}" class="shenhe">
				{if $val.status==0}审核{/if}
				{if $val.status==1}取消审核{/if}
			</a>&nbsp;&nbsp;
			<a href="?url=item/update&id={$val.id}">
				<img src="{gen_theme_url('images/i.gif')}" class="ico_edit" title="编辑">
			</a>&nbsp;&nbsp;
			<a href="?url=item/delete&id={$val.id}" class="delete">
				<img src="{gen_theme_url('images/i.gif')}" class="ico_del" title="删除">
			</a>
		</td>
	</tr>
	{/foreach}
</table>
</form>
<script type="text/javascript" charset="utf-8">
	$(".shenhe").click(function(){
		var self = $(this);
		var id = self.attr('href');
		$.get('?url=item/shenhe&id='+id, function(data){
			if (data==1) {
				self.html('取消审核').parent().prev().prev().prev().html('已审核');
			};
			if (data==0) {
				self.html('审核').parent().prev().prev().prev().html('未审核');
			};
		})
		return false;
	});
	
	$(".tuijian").click(function(){
		var self = $(this);
		var id = self.attr('href');
		$.get('?url=item/tuijian&id='+id, function(data){
			if (data==1) {
				self.html('取消推荐').parent().prev().prev().prev().prev().html('<font color="red">是</font>');
			};
			if (data==0) {
				self.html('推荐').parent().prev().prev().prev().prev().html('否');
			};
		})
		return false;
	});
</script>
<div class="btn_blk">
	<div class="fr">
		<a href="#" class="btn2 fr ml20 del_all">删除</a>
	</div>
	{include file="lib/pager.html"}

</div>

<script type="text/javascript" charset="utf-8">
$('.del_all').click(function(){
	var check = $(":checkbox:checked").size();
	if (!check) {
		alert('你还没有选择要删除的资源');
		return false;
	};
	$("#res_del").submit();
  return false;
});
</script>

{/block}
